using System;

namespace HelloWorld.Learn
{
    class Digit
    {
        public Digit(double d)
        {
            val = d;
        }
        
        public double val;

        public static implicit operator double(Digit d)
        {
            return d.val;
        }

        public static implicit operator Digit(double d)
        {
            return new Digit(d);
        }

        public override string ToString()
        {
            return val.ToString();
        }
    }

    public class ImplicitDemo
    {
        public static void Demo()
        {
            var d = new Digit(12.7);
            double num = d;

            Digit d2 = 25.8d;

            Console.WriteLine("num = {0} dig2 = {1}", num, d2);
        }
    }
}